/* 基础样式重置 */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  font-size: 16px;
  overflow-x: hidden;
}

/* 响应式字体大小 */
@media screen and (max-width: 768px) {
  html {
    font-size: 14px;
  }
}

@media screen and (max-width: 480px) {
  html {
    font-size: 12px;
  }
}

/* 移动设备适配 */
@media screen and (max-width: 768px) {
  html {
    font-size: 14px;
  }

  .ant-layout {
    display: flex;
    flex-direction: column;
    min-width: 320px;
  }

  .ant-layout-header {
    padding: 0 8px;
    height: auto;
    line-height: 1.5;
  }

  .ant-layout-content {
    padding: 8px;
    flex: 1;
  }

  .course-list-container {
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
  }

  .course-card {
    margin: 4px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
  }

  .course-image-container {
    height: 120px;
    overflow: hidden;
  }

  .course-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .course-title {
    font-size: 1rem;
    margin: 8px 0;
  }

  .course-description {
    font-size: 0.875rem;
    line-height: 1.4;
    height: 2.8em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .course-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin: 8px 0;
  }

  .course-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
  }

  .video-container {
    margin: 8px 0;
  }

  .notes-container {
    padding: 8px;
  }

  .note-item {
    margin: 4px 0;
    padding: 8px;
  }

  .progress-drawer {
    width: 100% !important;
  }

  .chapter-progress {
    padding: 8px;
  }

  .qa-container {
    padding: 8px;
  }

  .question-item {
    margin: 8px 0;
    padding: 8px;
  }

  .answer-item {
    margin: 4px 0;
    padding: 8px;
  }

  .qa-form {
    padding: 8px;
  }

  .discussion-container {
    padding: 8px;
  }

  .post-item {
    margin: 8px 0;
    padding: 8px;
  }

  .comment-item {
    margin: 4px 0;
    padding: 8px;
  }

  .discussion-form {
    padding: 8px;
  }

  .profile-container {
    padding: 8px;
  }

  .user-info-card {
    margin: 8px 0;
    padding: 8px;
  }

  .profile-form {
    padding: 8px;
  }

  .avatar-upload {
    width: 80px;
    height: 80px;
    margin: 0 auto;
  }

  .admin-container {
    padding: 8px;
  }

  .statistics-card {
    margin: 8px 0;
    padding: 8px;
  }

  .user-management-table {
    margin: 8px 0;
  }

  .announcement-form {
    padding: 8px;
  }

  .ant-card {
    margin-bottom: 8px;
  }

  .ant-card-body {
    padding: 12px;
  }

  .ant-btn {
    padding: 4px 8px;
    font-size: 0.875rem;
    height: auto;
    line-height: 1.5;
  }

  .ant-input {
    padding: 4px 8px;
    font-size: 0.875rem;
  }

  .ant-select {
    font-size: 0.875rem;
  }

  .ant-select-selector {
    padding: 4px 8px;
  }

  .ant-table {
    font-size: 0.875rem;
  }

  .ant-table-thead>tr>th {
    padding: 8px;
  }

  .ant-table-tbody>tr>td {
    padding: 8px;
  }

  .ant-pagination {
    margin: 8px 0;
  }

  .ant-tag {
    font-size: 0.75rem;
    padding: 0 4px;
    margin: 2px;
  }

  .ant-progress {
    margin: 4px 0;
  }

  .ant-spin {
    margin: 8px 0;
  }
}

/* iOS 设备适配 */
@supports (-webkit-touch-callout: none) {
  .ant-layout {
    min-height: -webkit-fill-available;
  }

  .ant-input,
  .ant-btn {
    -webkit-appearance: none;
  }
}

/* Android 设备适配增强 */
@supports (-webkit-overflow-scrolling: touch) {
  .ant-layout {
    min-height: -webkit-fill-available;
  }

  /* Android 输入框优化 */
  .ant-input,
  .ant-input-password,
  .ant-select-selector {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-clip: padding-box;
    border-radius: 4px;
  }

  /* Android 按钮优化 */
  .ant-btn {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    touch-action: manipulation;
  }

  /* Android 滚动优化 */
  .ant-layout-content {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Android 视频播放器优化 */
  .video-js {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }

  /* Android 模态框优化 */
  .ant-modal {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }

  /* Android 菜单优化 */
  .ant-menu {
    -webkit-overflow-scrolling: touch;
  }
}

/* Android 低版本兼容性修复 */
@media screen and (-webkit-min-device-pixel-ratio:0) {
  .ant-layout {
    position: relative;
    z-index: 0;
  }

  .ant-modal-mask {
    position: fixed;
  }

  .ant-drawer-mask {
    position: fixed;
  }
}

/* IE11 兼容性修复 */
@media all and (-ms-high-contrast: none),
(-ms-high-contrast: active) {
  .ant-layout {
    display: -ms-flexbox;
    display: flex;
    -ms-flex-direction: column;
    flex-direction: column;
  }

  .ant-layout-content {
    -ms-flex: 1;
    flex: 1;
  }
}

/* 触摸设备优化 */
@media (hover: none) {

  .ant-btn,
  .ant-menu-item,
  .ant-tabs-tab {
    padding: 12px 16px;
  }

  .ant-input,
  .ant-select-selector {
    padding: 8px 12px;
  }
}

/* 高分辨率设备适配 */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
  .anticon {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* 暗黑模式支持 */
@media (prefers-color-scheme: dark) {
  :root {
    --background-color: #141414;
    --text-color: #ffffff;
  }

  .ant-layout {
    background-color: var(--background-color);
    color: var(--text-color);
  }
}

/* 字体平滑处理 */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* 滚动条样式统一 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* 移动端输入框优化 */
input,
textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-radius: 0;
}

/* 视频播放器响应式 */
.video-js {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
}

/* 图片响应式 */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* 表格响应式 */
.ant-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 表单响应式 */
.ant-form {
  max-width: 100%;
}

/* 模态框响应式 */
.ant-modal {
  max-width: 90%;
  margin: 16px auto;
}

/* 抽屉响应式 */
.ant-drawer {
  width: 100% !important;
  max-width: 400px;
}

/* 菜单响应式 */
.ant-menu {
  white-space: nowrap;
}

/* 按钮响应式 */
.ant-btn {
  white-space: nowrap;
}

/* 加载状态响应式 */
.ant-spin {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

/* 消息提示响应式 */
.ant-message {
  max-width: 90%;
  margin: 0 auto;
}

/* 通知响应式 */
.ant-notification {
  max-width: 90%;
  margin: 0 auto;
}

/* 平板设备适配 */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  .ant-layout-content {
    padding: 16px;
  }

  .course-card {
    margin: 12px;
  }

  .video-js {
    height: 300px;
  }
}

/* 桌面设备适配 */
@media screen and (min-width: 1025px) {
  .ant-layout-content {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
  }

  .course-card {
    margin: 16px;
  }

  .video-js {
    height: 400px;
  }
}

/* 超宽屏适配 */
@media screen and (min-width: 1600px) {
  .ant-layout-content {
    max-width: 1400px;
  }
}

/* 进一步优化移动设备适配 */
@media screen and (max-width: 480px) {
  html {
    font-size: 12px;
  }

  .ant-layout-header {
    padding: 0 4px;
    height: auto;
    line-height: 1.2;
  }

  .ant-layout-content {
    padding: 4px;
  }

  .course-list-container {
    padding: 4px;
  }

  .course-header {
    padding: 4px;
    text-align: center;
  }

  .course-filters {
    margin: 4px 0;
  }

  .course-card {
    margin: 2px;
    border-radius: 4px;
  }

  .course-image-container {
    height: 100px;
    overflow: hidden;
  }

  .course-title {
    font-size: 0.875rem;
    margin: 4px 0;
  }

  .course-description {
    font-size: 0.75rem;
    line-height: 1.2;
    height: 2.4em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .course-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.625rem;
    margin: 4px 0;
  }

  .course-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
  }

  .video-container {
    margin: 4px 0;
  }

  .notes-container {
    padding: 4px;
  }

  .note-item {
    margin: 2px 0;
    padding: 4px;
  }

  .progress-drawer {
    width: 100% !important;
  }

  .chapter-progress {
    padding: 4px;
  }

  .qa-container {
    padding: 4px;
  }

  .question-item {
    margin: 4px 0;
    padding: 4px;
  }

  .answer-item {
    margin: 2px 0;
    padding: 4px;
  }

  .qa-form {
    padding: 4px;
  }

  .discussion-container {
    padding: 4px;
  }

  .post-item {
    margin: 4px 0;
    padding: 4px;
  }

  .comment-item {
    margin: 2px 0;
    padding: 4px;
  }

  .discussion-form {
    padding: 4px;
  }

  .profile-container {
    padding: 4px;
  }

  .user-info-card {
    margin: 4px 0;
    padding: 4px;
  }

  .profile-form {
    padding: 4px;
  }

  .avatar-upload {
    width: 60px;
    height: 60px;
    margin: 0 auto;
  }

  .admin-container {
    padding: 4px;
  }

  .statistics-card {
    margin: 4px 0;
    padding: 4px;
  }

  .user-management-table {
    margin: 4px 0;
  }

  .announcement-form {
    padding: 4px;
  }

  .ant-card {
    margin-bottom: 4px;
  }

  .ant-card-body {
    padding: 8px;
  }

  .ant-btn {
    padding: 2px 4px;
    font-size: 0.75rem;
    height: auto;
    line-height: 1.2;
  }

  .ant-input {
    padding: 2px 4px;
    font-size: 0.75rem;
  }

  .ant-select {
    font-size: 0.75rem;
  }

  .ant-select-selector {
    padding: 2px 4px;
  }

  .ant-table {
    font-size: 0.75rem;
  }

  .ant-table-thead>tr>th {
    padding: 4px;
  }

  .ant-table-tbody>tr>td {
    padding: 4px;
  }

  .ant-pagination {
    margin: 4px 0;
  }

  .ant-tag {
    font-size: 0.625rem;
    padding: 0 2px;
    margin: 1px;
  }

  .ant-progress {
    margin: 2px 0;
  }

  .ant-spin {
    margin: 4px 0;
  }
}